from django.db import models


# Create your models here.
class Order(models.Model):
    RENT = [
        (0, "无"),
        (1, "短期租用"),
        (2, "长期租用")
    ]
    STATUS = [
        (1, "待审核"),
        (2, "未付款"),
        (3, "已付款"),
        (4, "已到期"),
    ]
    uid = models.IntegerField()
    rid = models.IntegerField()
    ctid = models.IntegerField(default=0)
    rent = models.IntegerField(choices=RENT)
    period = models.IntegerField()  # days or months
    status = models.IntegerField(default=1, choices=STATUS)
    startTime = models.CharField(max_length=255, null=True)
    endTime = models.CharField(max_length=255, null=True)
    price = models.FloatField(null=True)
    address = models.CharField(max_length=255, null=True)
    desc = models.TextField(null=True)

    def get_info(self):
        dic = dict()
        dic['oid'] = self.id
        dic['uid'] = self.uid
        dic['rid'] = self.rid
        dic['ctid'] = self.ctid
        dic['rent'] = self.rent
        dic['period'] = self.period
        dic['status'] = self.status
        dic['startTime'] = self.startTime
        dic['endTime'] = self.endTime
        dic['price'] = self.price
        dic['address'] = self.address
        dic['desc'] = self.desc
        return dic
